
package Controllers;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
 *
 * @author Tim
 */
public class GeldStorten implements ActionListener {

    /**
     *
     */
    public GUI.GeldStorten ggs;
    /**
     *
     */
    public String melding = "";

    /**
     *
     * @param gs
     */
    public GeldStorten(GUI.GeldStorten gs){
        this.ggs = gs;
    }

    /**
     *
     */
    public void stort(){
            //try{gww.gc.spelerIngelogd.setGebruikersnaam(gww.gebruikersnaamText.getText().trim());}catch(Exception e){melding +="\n " + e.getMessage();}
            try{ggs.gc.spelerIngelogd.setSaldo(ggs.saldoText.getText());}catch(Exception e){melding +="\n " + e.getMessage();}

            if(melding.length() < 1){
            JOptionPane.showMessageDialog(ggs.gc, "uw geld is gestort.");
            ggs.gc.setGUI("huidigetafel");
            }else{
            JOptionPane.showMessageDialog(ggs.gc,"De volgende velden zijn niet correct ingevuld: \n" + melding);
            melding = "";
        }
    }

    public void actionPerformed(ActionEvent e) {
        if(e.getSource() == ggs.stortButton){
            stort();
        }
    }
}
